fix(login): accept letter-based email OTP codes at the code prompt#69
Merged
Conversation
Email OTPs are six letters, but the login code prompt validated only
digits (/^\d{4,8}$/) and told users to enter a numeric code, so a real
email OTP could never be entered. Thread the login channel into the
getCode callback and make the prompt channel-aware: six letters
(case-insensitive, uppercased before verifying) for email, digits for
phone, with matching placeholder text.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
seamless loginwith an email identifier could never accept a real email OTP.The auth API generates email OTPs as 6 uppercase letters, but the CLI's code prompt validated with
/^\d{4,8}$/and told the user to "Enter the numeric code from the message." Every valid letter-based code was rejected, so email login was effectively broken. (Phone OTPs are digits and worked fine.)Fix
Make the code prompt channel-aware:
channel(email|phone) into thegetCodecallback ctx incompleteLogin— the flow already knew the channel internally; it just wasn't exposed to the prompt./^[A-Za-z]{6}$/, case-insensitive), normalize it to uppercase before verifying (the verify endpoint uppercases too), and show anABCDEFplaceholder with letter-specific guidance.123456placeholder.Tests
loginFlow.test.ts: assertschannelis passed togetCode.login.test.ts: email letter validation + placeholder, lowercase→uppercase normalization before verify, and phone digit validation.Full suite green (552 passed), typecheck clean. A
patchchangeset is included.Note: unrelated to
seamless login --local(which auto-fills the code and bypasses this prompt).